package com.bloveoacom.weichi.activity;

import android.os.Bundle;
import android.view.View;

import com.bloveoacom.base.BaseList2Activity;
import com.bloveoacom.base.UserInfoBean;
import com.bloveoacom.http.HttpMethods;
import com.bloveoacom.http.RxHelper;
import com.bloveoacom.observer.BaseSubscriber2;
import com.bloveoacom.util.ActivityUtil;
import com.bloveoacom.util.DataUtil;
import com.bloveoacom.util.NumberUtil;
import com.bloveoacom.weichi.R;
import com.bloveoacom.weichi.bean.MyFansBean;
import com.bloveoacom.weichi.bean.NewsPostBean;
import com.bloveoacom.weight.LlkjToolBar;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import butterknife.BindView;

/**
 * author: zhu.px
 * e-mail: 1271901673@qq.com
 * time  : 2018/7/12
 * desc  : 我的关注或者粉丝
 */
public class MyCollectActivity extends BaseList2Activity<NewsPostBean> {

    @BindView(R.id.title_bar)
    LlkjToolBar titleBar;


    @Override
    public int getLayoutResId() {
        return R.layout.layout_refresh_title;
    }

    @Override
    public void initView() {
        super.initView();
        titleBar.setToolBar("我的收藏",
                true, "", R.drawable.ic_back, false, "", R.drawable.ic_search);
    }


    @Override
    protected View getViewSetTB() {
        return titleBar;
    }

    @Override
    public void getBundleExtras(Bundle extras) {

    }



    @Override
    protected int getItemLayout() {
        return R.layout.rv_item_post2;
    }

    @Override
    protected void convertView(BaseViewHolder helper, NewsPostBean item) {
       DataUtil.setItemView2(mContext,helper,item,2);
        helper.setVisible(R.id.group2,false);
        helper.setVisible(R.id.group,true);
    }



    @Override
    protected void getData() {
        BaseSubscriber2<List<NewsPostBean>> baseSubscriber = HttpMethods.getInstance().getHttpService().queryUserCollectList(UserInfoBean.getInstance().getToken(), page, HttpMethods.PAGE_SIZE).compose(RxHelper.getData()).subscribeWith(new BaseSubscriber2<List<NewsPostBean>>(this) {
            @Override
            public void onNext(List<NewsPostBean> o) {
                doData(o);
            }
        });
        addDispose(baseSubscriber);

    }


    MyFansBean bean;
    @Override
    public void initListener() {
        adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Bundle bundle = new Bundle();
                bundle.putInt(PostDetailActivity.COINID, NumberUtil.getIntByStr(datas.get(position).coinId));
                ActivityUtil.startActivity(mContext, PostDetailActivity.class, bundle);
            }
        });
        titleBar.setRightButtonOnClickLinster(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
    }

}
